#include "DefinitionTable.h"

vector<DefTableRow> DefinitionTable::table;

DefinitionTable::DefinitionTable() {};

void DefinitionTable::setDefinition(TYPE type, string name) {
	DefTableRow row = DefTableRow(type, name);
	table.push_back(row);
}

void DefinitionTable::clearTable() {
	table.clear();
}

bool DefinitionTable::isNamePresent(string name) {
	for ( int i = 0; i < table.size(); ++i ) {
		if ( table.at(i).getName().compare(name)==0 )
			return true;
	}
	return false;
}

TYPE DefinitionTable::getType(string name) {
	for ( int i = 0; i < table.size(); ++i ) {
		if ( table.at(i).getName().compare(name)==0 ) {
			return table.at(i).getType();
		}
	}
	return NONE;
}

TYPE DefinitionTable::getType(int index) {
	return getType(getName(index));
}

int DefinitionTable::getIndex(string name) {
	for ( int i = 0; i < table.size(); ++i ) {
		if ( table.at(i).getName().compare(name)==0 ) {
			return i;
		}
	}
	return -1;
}
string DefinitionTable::getName(int index) {
	return table.at(index).getName();
}